<template>
  <div class="cbody">
    <div style="padding: 10px">
      <el-container>
        <el-header style="height: 20px">
          <div>
            <el-date-picker
              v-model="query.sddate"
              class="search-inp"
              align="right"
              type="date"
              placeholder="单据日期"
            />
            <el-date-picker
              v-model="query.eddate"
              class="search-inp"
              align="right"
              type="date"
              placeholder="单据日期"
            />
            <el-input v-model="query.mocode" class="search-inp" placeholder="单号" />
            <el-input v-model="query.csocode" class="search-inp" placeholder="需求单号" />
            <el-date-picker
              v-model="query.screate"
              class="search-inp"
              align="right"
              type="date"
              placeholder="创建日期"
            />
            <el-date-picker
              v-model="query.ecreate"
              class="search-inp"
              align="right"
              type="date"
              placeholder="创建日期"
            />
            <el-select
              v-model="query.measurement"
            >
              <el-option
                v-for="item in ['','未检','已检','合格','特采','全检','返工']"
                :key="item"
                :label="item"
                :value="item"
              />
            </el-select>
            <el-button class="hand-btn" type="primary" icon="el-icon-search" @click="handleSearch">查询</el-button>
          </div>
        </el-header>
        <el-main>
          <el-table
            :data="page.content"
            max-height="560"
            height="560"
            :cell-style="{'padding':'2px','font-size':'12px'}"
            :header-cell-style="{'padding':'0px','font-weight':'800'}"
            tooltip-effect="dark"
            border
            style="width: 100%;"
          >
            <el-table-column
              type="index"
              label="项次"
              width="50"
            />
            <el-table-column width="80" prop="measurement" label="总检" />
            <el-table-column
              label="板号"
              width="140px"
            >
              <template slot-scope="scope">
                <div scroll-y="true" style="overflow:auto;height: 20px">
                  <div v-for="(item, index) in scope.row.barcodes" :key="index">
                    {{ item.cbarcode }}-{{ item.kbno }}
                  </div>
                </div>
              </template>
            </el-table-column>
            <el-table-column width="110" prop="billno" label="入库单号" />
            <el-table-column width="100" prop="ddate" label="来料日期" />
            <el-table-column width="100" prop="ccode" label="来料单号" />
            <el-table-column width="120" prop="cinvcode" label="产品编码" />
            <el-table-column width="300" prop="cinvname" label="产品名称" />
            <el-table-column width="230" prop="cvenname" label="供应商名称" />
            <el-table-column width="80" prop="qcyqty" label="检测数" />
            <el-table-column width="80" prop="createBy" label="创建人" />
            <el-table-column width="160" prop="createTime" label="创建时间" />
            <el-table-column width="130" prop="cdepname" label="部门名称" />
            <el-table-column label="操作" width="240" align="center" fixed="right">
              <template slot-scope="scope">
                <el-button
                  type="text"
                  icon="el-icon-edit"
                  style="color: #52b0fd"
                  @click="show(scope.row)"
                >查看</el-button>
                <el-button
                  v-show="!scope.row.measurement"
                  type="text"
                  icon="el-icon-edit"
                  style="color: #52b0fd"
                  @click="selTable(scope.row)"
                >编辑</el-button>
                <el-button
                  v-show="!scope.row.measurement"
                  type="text"
                  icon="el-icon-edit"
                  style="color: #52b0fd"
                  @click="qualityBill(scope.$index, scope.row)"
                >总检</el-button>
                <el-button
                  v-show="!scope.row.measurement"
                  type="text"
                  icon="el-icon-delete"
                  class="red"
                  @click="handleDelete(scope.$index, scope.row)"
                >删除</el-button>
                <!--<el-button-->
                <!--type="text"-->
                <!--icon="el-icon-delete"-->
                <!--class="red"-->
                <!--@click="handleDelete(scope.$index, scope.row)"-->
                <!--&gt;免检</el-button>-->
              </template>
            </el-table-column>
          </el-table>
        </el-main>
        <el-footer>
          <div class="pagination">
            <el-pagination
              background
              layout="total,sizes, prev, pager, next"
              :page-sizes="[10,20, 30, 40, 50]"
              :current-page="query.pageIndex"
              :page-size="query.pageSize"
              :total="page.totalElements"
              @size-change="handleSizeChange"
              @current-change="handlePageChange"
            />
          </div>
        </el-footer>
      </el-container>
    </div>
    <!----------------------------------form 表单------------------down----------- -->
    <el-dialog :visible.sync="qualityViible">
      <el-form ref="form" :model="form" label-width="50px">
        <el-form-item label="备注" prop="remark">
          <el-input v-model="form.remark" />
        </el-form-item>
        <el-form-item label="判定" prop="measurement">
          <el-radio-group v-model="form.measurement">
            <el-radio label="合格">合格</el-radio>
            <el-radio label="特采">特采</el-radio>
            <el-radio label="全检">全检</el-radio>
            <el-radio label="返工">返工</el-radio>
          </el-radio-group>
        </el-form-item>
      </el-form>
      <div style="text-align:right">
        <el-button class="hand-btn" type="info" @click="qualityViible = !qualityViible">取消</el-button>
        <el-button class="hand-btn" type="success" @click="saveEdit">保存</el-button>
      </div>
    </el-dialog>

    <el-dialog :visible.sync="showView" width="1000px">
      <div>
        <el-button v-print="print" icon="el-icon-printer" size="medium">打印</el-button>
        <div>
          <div id="printMe" ref="printMe" class="content">
            <div style="text-align: center">
              <div style="font-size: 20px"><span>KENNEDE</span><span>广东金莱特智能科技有限公司</span></div>
              <div style="font-size: 17px">产品质检报告</div>
            </div>
            <div style="display: flex;justify-content: space-between;margin-right: 10px">
              <div style="display: flex;justify-content: space-between;margin-right: 10px" />
              <div style="display: flex;justify-content: space-between;margin-right: 10px">
                <div>
                  <label><input v-model="form.billtype" disabled="disabled" type="radio" value="生产质检" name="billtype">生产质检</label>
                </div>
                <div>
                  <label><input v-model="form.billtype" disabled="disabled" type="radio" value="最终质检" name="billtype">最终质检</label>
                </div>
                <div>
                  <label><input v-model="form.billtype" disabled="disabled" type="radio" value="半成品" name="billtype">半成品</label>
                </div>
                <div>
                  <label><input v-model="form.billtype" disabled="disabled" type="radio" value="成品" name="billtype">成品</label>
                </div>
              </div>
              <div>
                抽样标准:GB2828.1-2012
              </div>
            </div>
            <!-------------------------------表格 ----------------------down ------------------->
            <table class="table">
              <thead>
              <tr>
                <td class="topth">
                  拉别/品牌
                </td>
                <td> {{form.cdefine33}}/{{form.cfree2}}</td>
                <td class="topth">
                  单号/生产日期
                </td>
                <td> {{ form.ccode }}/{{ form.ddate }}</td>
                <td> {{ form.ddate }}</td>
                <td class="topth">
                  需求跟踪号
                </td>
                <td> {{ form.csocode }}</td>
              </tr>
              <tr>
                <td class="topth">
                  产品型号
                </td>
                <td> {{ form.csoinvname }}</td>
                <td class="topth">
                  产品数量
                </td>
                <td>{{ form.qty }} </td>
                <td class="topth">
                  抽样数
                </td>
                <td> {{form.checkqty}} </td>
              </tr>
              </thead>
            </table>
            <!-------------------------------主信息 ----------------------up ------------------->
            <!-------------------------------下拉选择 ----------------------up ------------------->
            <table class="table">
              <thead>
                <tr>
                  <th width="50px" rowspan="3">
                    产品要求核对
                  </th>
                  <th class="mincell" rowspan="2">
                    过充
                  </th>
                  <th class="mincell" rowspan="2">
                    过放
                  </th>
                  <th class="mincell" rowspan="2">
                    DC
                  </th>
                  <th class="mincell" rowspan="2">
                    AC
                  </th>
                  <th class="mincell" rowspan="2">
                    S-AC
                  </th>
                  <th class="mincell" rowspan="2">
                    电压
                  </th>
                  <th class="mincell" rowspan="2">
                    电源线
                  </th>
                  <th class="mincell" rowspan="2">
                    充电
                  </th>
                  <th class="mincell" rowspan="2">
                    拉线开关
                  </th>
                  <th class="mincell" rowspan="2">
                    检测开关
                  </th>
                  <th class="mincell" rowspan="2">
                    反光纸
                  </th>
                  <th class="mincell" rowspan="2">
                    防水
                  </th>
                  <th class="mincell" rowspan="2">
                    外置天线
                  </th>

                  <th class="mincell" colspan="2">
                    LED
                  </th>
                  <th class="mincell" colspan="3">
                    电筒功能
                  </th>
                  <th class="mincell" colspan="2">
                    射灯
                  </th>
                  <th class="mincell" colspan="2">
                    电池
                  </th>
                  <th class="mincell" rowspan="2">
                    使用时间
                  </th>
                  <th class="mincell" colspan="2">
                    索件
                  </th>
                  <th class="mincell" rowspan="2">
                    整灯
                  </th>
                  <th class="mincell" rowspan="2">
                    散件
                  </th>
                </tr>
                <tr>
                  <th class="mincell">
                    串
                  </th>
                  <th class="mincell">
                    并
                  </th>
                  <th class="mincell">
                    单
                  </th>
                  <th class="mincell">
                    双
                  </th>
                  <th class="mincell">
                    三
                  </th>
                  <th class="mincell">
                    LED
                  </th>
                  <th class="mincell">
                    灯珠
                  </th>
                  <th class="mincell">
                    片数
                  </th>
                  <th class="mincell">
                    重量
                  </th>
                  <th class="mincell">
                    用料
                  </th>
                  <th class="mincell">
                    颜色配置
                  </th>
                </tr>
                <tr>
                  <td>
                    {{ form.guochong }}
                  </td>
                  <td>
                    {{ form.guofang }}
                  </td>
                  <td>
                    {{ form.dc }}
                  </td>
                  <td>
                    {{ form.ac }}
                  </td>
                  <td>
                    {{ form.sac }}
                  </td>
                  <td>
                    {{ form.dianya }}
                  </td>
                  <td>
                    {{ form.dianyuanxian }}
                  </td>
                  <td>
                    {{ form.chondian }}
                  </td>
                  <td>
                    {{ form.laxiankaiguan }}
                  </td>
                  <td>
                    {{ form.jiancekaiguan }}
                  </td>
                  <td>
                    {{ form.fanguangzhi }}
                  </td>
                  <td>
                    {{ form.fangshui }}
                  </td>
                  <td>
                    {{ form.waizhitianxian }}
                  </td>
                  <td>
                    {{ form.ledchuan }}
                  </td>
                  <td>
                    {{ form.ledbing }}
                  </td>
                  <td>
                    {{ form.diantongdan }}
                  </td>
                  <td>
                    {{ form.diantongshuang }}
                  </td>
                  <td>
                    {{ form.diantongsan }}
                  </td>
                  <td>
                    {{ form.shedengled }}
                  </td>
                  <td>
                    {{ form.shedengdanzhu }}
                  </td>
                  <td>
                    {{ form.dianchipainshu }}
                  </td>
                  <td>
                    {{ form.dianchizhongliang }}
                  </td>
                  <td>
                    {{ form.shiyongshijian }}
                  </td>
                  <td>
                    {{ form.suojianyongliao }}
                  </td>
                  <td>
                    {{ form.suojianyanse }}
                  </td>
                  <td>
                    {{ form.zhengdeng }}
                  </td>
                  <td>
                    {{ form.sandjian }}
                  </td>
                </tr>
                <tr>
                  <th width="50px" rowspan="3">
                    包装及丝印核对
                  </th>
                  <th class="mincell" rowspan="2">
                    客户型号
                  </th>
                  <th class="mincell" rowspan="2">
                    品牌
                  </th>
                  <th class="mincell" rowspan="2">
                    光管
                  </th>
                  <th class="mincell" rowspan="2">
                    电池
                  </th>
                  <th class="mincell" rowspan="2">
                    塑件
                  </th>
                  <th class="mincell" rowspan="2">
                    PCS/CN
                  </th>
                  <th class="mincell" rowspan="2">
                    内包装
                  </th>
                  <th class="mincell" rowspan="2">
                    彩盒
                  </th>
                  <th class="mincell" rowspan="2">
                    说明书保修卡等
                  </th>
                  <th class="mincell" rowspan="2">
                    胶袋⌒ 文字 ︶
                  </th>
                  <th class="mincell" rowspan="2">
                    正唛
                  </th>
                  <th class="mincell" rowspan="2">
                    侧唛
                  </th>

                  <th class="mincell" colspan="8">
                    标贴
                  </th>
                  <th class="mincell" colspan="7" rowspan="2">
                    卡通（颜色/字体/文字/封箱胶）
                  </th>
                </tr>
                <tr>
                  <th class="mincell">
                    产地标
                  </th>
                  <th class="mincell">
                    QC标
                  </th>
                  <th class="mincell">
                    电压标
                  </th>
                  <th class="mincell">
                    封口标
                  </th>
                  <th class="mincell">
                    条形标
                  </th>
                  <th class="mincell">
                    认证标
                  </th>
                  <th class="mincell" colspan="2">
                    其它标
                  </th>
                </tr>
                <tr>
                  <td>
                    {{ form.kehuxinghao }}
                  </td>
                  <td>
                    {{ form.pingpai }}
                  </td>
                  <td>
                    {{ form.guangguan }}
                  </td>
                  <td>
                    {{ form.dianchi }}
                  </td>
                  <td>
                    {{ form.suojian }}
                  </td>
                  <td>
                    {{ form.pcs }}
                  </td>
                  <td>
                    {{ form.neibaozhuang }}
                  </td>
                  <td>
                    {{ form.caihe }}
                  </td>
                  <td>
                    {{ form.shuomingshu }}
                  </td>
                  <td>
                    {{ form.jiaodai }}
                  </td>
                  <td>
                    {{ form.zhengsuo }}
                  </td>
                  <td>
                    {{ form.cesuo }}
                  </td>
                  <td>
                    {{ form.chandibiao }}
                  </td>
                  <td>
                    {{ form.qcbiao }}
                  </td>
                  <td>
                    {{ form.dianyabiao }}
                  </td>
                  <td>
                    {{ form.fengkoubiao }}
                  </td>
                  <td>
                    {{ form.tiaoxingbiao }}
                  </td>
                  <td>
                    {{ form.renzhengbiao }}
                  </td>
                  <td colspan="2">
                    {{ form.qitabiao }}
                  </td>
                  <td colspan="7">
                    {{ form.katong }}
                  </td>
                </tr>
              </thead>
            </table>
            <!-------------------------------下拉选择 ----------------------up ------------------->
            <!-------------------------------大表格 ----------------------down ------------------->
            <table class="table">
              <tr>
                <th>
                  检测项目
                </th>
                <th>
                  检测内容
                </th>
                <th width="20px">
                  轻缺陷数量
                </th>
                <th width="20px">
                  重缺陷数量
                </th>
                <th width="20px">
                  致命缺陷数量
                </th>
              </tr>
              <tr>
                <td width="100px" rowspan="3">
                  外观
                </td>
                <td>
                  <textarea v-model="form.baozhuang" rows="3" cols="60" placeholder="包装：" disabled="disabled" />
                </td>
                <td>
                  <input v-model="form.wgq1" type="number" min="0" class="cnumber" disabled="disabled">
                </td>
                <td>
                  <input v-model="form.wgz1" type="number" min="0" class="cnumber" disabled="disabled">
                </td>
                <td>
                  <input v-model="form.wgzm1" type="number" min="0" class="cnumber" disabled="disabled">
                </td>
              </tr>
              <tr>
                <td>
                  <textarea v-model="form.waiguan" rows="3" cols="60" placeholder="外观：" disabled="disabled" />
                </td>
                <td>
                  <input v-model="form.wgq2" type="number" min="0" class="cnumber" disabled="disabled">
                </td>
                <td>
                  <input v-model="form.wgz2" type="number" min="0" class="cnumber" disabled="disabled">
                </td>
                <td>
                  <input v-model="form.wgzm2" type="number" min="0" class="cnumber" disabled="disabled">
                </td>
              </tr>
              <tr>
                <td>
                  <textarea v-model="form.jiegouzuzhuang" rows="3" cols="60" placeholder="结构组装：" disabled="disabled" />
                </td>
                <td>
                  <input v-model="form.wgq3" type="number" min="0" class="cnumber" disabled="disabled">
                </td>
                <td>
                  <input v-model="form.wgz3" type="number" min="0" class="cnumber" disabled="disabled">
                </td>
                <td>
                  <input v-model="form.wgzm3" type="number" min="0" class="cnumber" disabled="disabled">
                </td>
              </tr>
              <tr>
                <td width="100px">
                  性能
                </td>
                <td>
                  <table class="intable">
                    <tr>
                      <td>充电方式:</td><td><input v-model="form.chongdianfangshi" disabled="disabled"></td>
                    </tr>
                    <tr>
                      <td>电池批号:</td><td><input v-model="form.dianchipihao" disabled="disabled"></td>
                    </tr>
                    <tr>
                      <td>充电电流标准:</td><td><input v-model="form.chongdiandianliubiaozhun" disabled="disabled"></td>
                      <td>测试值:</td><td><input v-model="form.ceshi1" disabled="disabled"></td>
                    </tr>
                    <tr>
                      <td>漏电流标准:</td><td><input v-model="form.loudianliubiaozhun" disabled="disabled"></td>
                      <td>测试值:</td><td><input v-model="form.ceshi2" disabled="disabled"></td>
                    </tr>
                    <tr>
                      <td>工作电流标准:</td><td><input v-model="form.gongzuodianliubiaozhun" disabled="disabled"></td>
                      <td>测试值:</td><td><input v-model="form.ceshi3" disabled="disabled"></td>
                    </tr>
                    <tr>
                      <td /><td><input v-model="form.kongbai1" disabled="disabled"></td>
                      <td>测试值:</td><td><input v-model="form.ceshi4" disabled="disabled"></td>
                    </tr>
                    <tr>
                      <td /><td><input v-model="form.kongbai2" disabled="disabled"></td>
                      <td>测试值:</td><td><input v-model="form.ceshi5" disabled="disabled"></td>
                    </tr>
                    <tr>
                      <td /><td><input v-model="form.kongbai3" disabled="disabled"></td>
                      <td>测试值:</td><td><input v-model="form.ceshi6" disabled="disabled"></td>
                    </tr>
                  </table>
                  <textarea v-model="form.gongnengceshi" rows="3" cols="60" placeholder="性能测试：" disabled="disabled" />
                </td>
                <td>
                  <input v-model="form.wgq4" type="number" min="0" class="cnumber" disabled="disabled">
                </td>
                <td>
                  <input v-model="form.wgz4" type="number" min="0" class="cnumber" disabled="disabled">
                </td>
                <td>
                  <input v-model="form.wgzm4" type="number" min="0" class="cnumber" disabled="disabled">
                </td>
              </tr>
            </table>
            <!-------------------------------div ----------------------down ------------------->
            <div class="condiv">
              <div class="ditem">
                <div>
                  <div class="lditem">
                    落地测试：{{ form.downtest }}
                  </div>
                  <div class="lditem" style="display: flex">
                    <div>高压测试</div>
                    <div class="wditem">
                      <div><label><input v-model="form.gaoya" disabled="disabled" name="gaoya" value="1" class="gaoya" type="radio"> 1500V  5mA  3秒</label></div>
                      <div><label><input v-model="form.gaoya" disabled="disabled" name="gaoya" value="2" class="gaoya" type="radio"> 3000V  5mA  3秒  </label></div>
                      <div><label><input v-model="form.gaoya" disabled="disabled" name="gaoya" value="3" class="gaoya" type="radio"> <input v-model="form.gaoyai" disabled="disabled" type="number" style="width: 60px"> V 5mA  3秒 </label></div>
                    </div>
                  </div>
                  <div>
                    <div class="lditem">
                      检测水平：<select v-model="form.level" style="width: 200px" disabled="disabled" @change="changeLevel">
                        <option v-for="(item,index) in levels" :key="index" :value="item">{{ item }}</option>
                      </select>
                    </div>
                    <div class="lditem">
                      结果：
                      <span class="mditem">A<input v-model="form.jieguoa" disabled="disabled" class="mditem minp" type="number">台</span>
                      <span>B<input v-model="form.jieguob" disabled="disabled" class="mditem minp" type="number">台</span>
                      <span class="mditem">C<input v-model="form.jieguoc" disabled="disabled" class="mditem minp" type="number">台</span>
                    </div>
                  </div>
                </div>
                <div>
                  <div class="lditem">
                    AQL值：
                    <span>
                      A：<select v-model="form.aqla" style="width: 100px" disabled="disabled" @change="changeAqla">
                        <option v-for="(item,index) in grades" :key="index" :value="item">{{ item }}</option>
                      </select>
                    </span>
                    <span>
                      B：<select v-model="form.aqlb" style="width: 100px" disabled="disabled" @change="changeAqlb">
                        <option v-for="(item,index) in grades" :key="index" :value="item">{{ item }}</option>
                      </select>
                    </span>
                    <span>
                      C：<select v-model="form.aqlc" style="width: 100px" disabled="disabled" @change="changeAqlc">
                        <option v-for="(item,index) in grades" :key="index" :value="item">{{ item }}</option>
                      </select>
                    </span>
                  </div>
                  <div class="lditem" style="display: flex">
                    AC/RE值：
                    <div class="uspan">
                      A:<u>__{{ form.aca }}__/___{{ form.rea }}__</u>
                    </div>
                    <div class="uspan">
                      B:<u>__{{ form.acb }}__/__{{ form.reb }}__</u>
                    </div>
                    <div class="uspan">
                      C:<u>__{{ form.acc }}__/__{{ form.rec }}__</u>
                    </div>
                  </div>
                  <div style="display: flex">
                    <div>
                      判定：
                    </div>
                    <div>
                      <div>
                        <label class="">合格：<input v-model="form.panding" name="panding" value="合格" type="radio" class="mditem" disabled="disabled"></label>
                        <label>不合格：<input v-model="form.panding" name="panding" value="不合格" type="radio" class="mditem" disabled="disabled"></label>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
              <hr>
              <div style="display: flex;justify-content: space-between">
                <div>检测员/日期：{{ form.createBy }}/{{ form.createTime }}</div>
                <div>审核员/日期：{{ form.updateBy }}/{{ form.updateTime }}</div>
                <div>审批/日期：</div>
              </div>
              <hr>
              <div>品质经理评审意见：{{ form.remark }}</div>
            </div>
            <div style="text-align: left;display: flex">
              <div>
                备注：
              </div>
              <div>
                <div>①严格按生产通知单要求进行核对及检验，核对部门打“√”“x”“/”</div>
                <div>&nbsp;&nbsp;②半成品判定及成品的过程检验由检验部门负责人确认即可;</div>
                <div>&nbsp;&nbsp;③成品的最终检验报告若不合格，雷上报品质部;</div>
                <div>&nbsp;&nbsp;④此表由检验部门存档。本:D/0</div>
              </div>
            </div>
            <hr>
            <div style="text-align: left">
              版本:D/0
            </div>
            <!--<div class="condiv" >
              <el-upload
                :action="fileUploadURL"
                list-type="picture-card"
                :on-success="handleUploadSuccess"
                :on-preview="handlePictureCardPreview"
                :on-exceed="handleExceed"
                :limit="6"
                :file-list="filList"
                :on-remove="handleRemove"
              >
                <i class="el-icon-plus" />
              </el-upload>
              <el-dialog :visible.sync="dialogVisible">
                <img width="100%" :src="dialogImageUrl" alt="">
              </el-dialog>
            </div>-->
            <!-- 打印的按钮，显示打印预览 -->

          </div>
        </div>
      </div>

    </el-dialog>
  </div>
</template>
<script>import { query } from '@/api/rpincome'
import { save } from '@/api/rpincome'
import { delbyid } from '@/api/rpincome'
import { get } from '@/api/qmilcode'
export default {
  name: 'Qm105e',
  data() {
    return {
      print: {
        id: 'printMe'
      },
      showView: false,
      downtests: ['合格', '不合格', '不适用'],
      dialogVisible: false,
      dialogImageUrl: '',
      editVisible: false,
      qualityViible: false,
      filList: [],
      fileURL: process.env.VUE_APP_BASE_API,
      fileUploadURL: process.env.VUE_APP_BASE_API + '/file/upload',
      form: {},
      query: {
        pageIndex: 1,
        pageSize: 10,
        name: '',
        screate: new Date(),
        ecreate: new Date()
      },
      page: [],
      grades: [0, 0.25, 0.4, 0.65, 1.0, 1.5, 2.5, 4.0, 6.5, 10, 15, 25],
      levels: ['S-1', 'S-2', 'S-3', 'S-4', 'I', 'II', 'III'],
      options: ['/', '√', '×'],
      datas: []
    }
  },
  created() {
    this.handleSearch()
  },
  methods: {
    // 触发搜索按钮
    handleSearch() {
      this.$set(this.query, 'pageIndex', 1)
      this.getData()
    },
    handlePageChange(val) {
      this.$set(this.query, 'pageIndex', val)
      this.getData()
    },
    // 分页大小改变
    handleSizeChange(val) {
      this.$set(this.query, 'pageSize', val)
      this.getData()
    },
    getData() {
      query(this.query).then(res => {
        this.page = res.data.page
      })
    },
    selTable(row) {
      this.$router.push({ path: 'rpComeEdit', query: { id: row.id }})
      this.editVisible = true
    },
    saveEdit() {
      save(this.form).then(res => {
        if (res.code === 200) {
          this.editVisible = false
          this.qualityViible = false
          this.$message.success('保存成功!')
        } else {
          this.$message.error(res.medium)
        }
      })
    },
    qualityBill(index, row) {
      this.qualityViible = true
      this.form = row
    },
    // 删除操作
    handleDelete(index, row) {
      // 二次确认删除
      this.$confirm('确定要删除吗？', '提示', {
        type: 'warning'
      }).then(() => {
        delbyid(row.id).then(res => {
          this.$message.success('删除成功')
          this.getData()
        })
      })
        .catch(() => {
        })
    },
    changeAqla() {
      if (!this.form.level) {
        this.$message({
          showClose: true,
          message: '请检测质检等级',
          type: 'warning'
        })
        return
      }
      if (!this.form.qty) {
        this.$message({
          showClose: true,
          message: '请先选择单据',
          type: 'warning'
        })
        return
      }
      if (this.form.aqla === 0) {
        this.form.aca = 0
        this.form.rea = 0
      } else {
        const data = { level: this.form.level, qty: this.form.qty, grade: this.form.aqla }
        get(data).then(res => {
          this.form.aca = res.data.data.ac
          this.form.rea = res.data.data.re
          this.form = JSON.parse(JSON.stringify(this.form))
        })
      }
    },
    changeAqlb() {
      if (!this.form.level) {
        this.$message({
          showClose: true,
          message: '请检测质检等级',
          type: 'warning'
        })
        return
      }
      if (!this.form.qty) {
        this.$message({
          showClose: true,
          message: '请先选择单据',
          type: 'warning'
        })
        return
      }
      if (this.form.aqlb === 0) {
        this.form.acb = 0
        this.form.reb = 0
      } else {
        const data = { level: this.form.level, qty: this.form.qty, grade: this.form.aqlb }
        get(data).then(res => {
          this.form.acb = res.data.data.ac
          this.form.reb = res.data.data.re
          this.form = JSON.parse(JSON.stringify(this.form))
        })
      }
    },
    changeAqlc() {
      if (!this.form.level) {
        this.$message({
          showClose: true,
          message: '请检测质检等级',
          type: 'warning'
        })
        return
      }
      if (!this.form.qty) {
        this.$message({
          showClose: true,
          message: '请先选择单据',
          type: 'warning'
        })
        return
      }
      if (this.form.aqlc === 0) {
        this.form.acc = 0
        this.form.rec = 0
      } else {
        const data = { level: this.form.level, qty: this.form.qty, grade: this.form.aqlc }
        get(data).then(res => {
          this.form.acc = res.data.data.ac
          this.form.rec = res.data.data.re
          this.form = JSON.parse(JSON.stringify(this.form))
        })
      }
    },
    changeLevel() {
      if (this.form.aqla) {
        this.changeAqla()
      }
      if (this.form.aqlb) {
        this.changeAqlb()
      }
      if (this.form.aqlc) {
        this.changeAqlc()
      }
    },
    handleRemove(file, fileList) {
      const images = []
      for (const image of fileList) {
        if (image.response) {
          images.push({ imgUrl: image.response.data.data })
        } else {
          images.push({ imgUrl: image.url.replace(this.fileURL, '') })
        }
      }
      this.form.images = images
    },
    handlePictureCardPreview(file) {
      this.dialogImageUrl = file.url
      this.dialogVisible = true
    },
    handleExceed() {
      this.$message({
        showClose: true,
        message: '超出限定图片上传个数',
        type: 'error'
      })
    },
    show(row) {
      this.form = row
      this.showView = true
    },
    handleUploadSuccess(res, file, fileList) {
      const images = []
      for (const image of fileList) {
        if (image.response) {
          images.push({ imgUrl: image.response.data.data })
        } else {
          images.push({ imgUrl: image.url.replace(this.fileURL, '') })
        }
      }
      this.form.images = images
    }
  }
}
</script>
<style media="print">
  @page {
    size:  auto;
    margin: 1mm;
  }
  #printMe {
    margin: 0;
    height:auto
  }
</style>

<style scoped="css">
  .cbody{
    background-color: #fcfcfc;
  }
  select{
    -webkit-appearance:none;
    -moz-appearance:none;
    appearance:none;
  }
  .content{
    margin: 5px auto;
    width: 900px;
    padding: 20px;
    font-size: 14px;
    font-weight: 400;
    background-color: #f7f7f7;
    text-align: center;
  }
  .topth{
    width: 100px;
  }
  .condiv{
    text-align: left;
    border-width: thin;
    border-color: #c7c7c7;
    border-style: solid;
  }
  .table{
    border-collapse: collapse;
    border-color: #c7c7c7;
  }
  .lditem{
    margin: 5px 0;
  }
  .wditem{
    margin: 0 15px;
  }
  .uspan{
    margin: 0 5px;
  }
  .mditem{
    margin: 0 8px;
  }
  .minp{
    width: 50px;
  }
  td{
    border-style: solid;
    border-width: thin;
    border-color: #c7c7c7;
  }
  .handle-input {
    margin: 10px;
    width: 300px;
    display: inline-block;
  }
  .table {
    width: 100%;
  }
  .mincell{
    width: 20px;
  }
  col2{
    colspan:2
  }
  .cselect{
    height: 20px;
    width: 100%;
    text-align: center;
    border-width: 0;
    background-color: #ffffff;
    font-weight: bold;
  }
  th{
    border-style: solid;
    border-width: thin;
    font-weight: 400;
    border-color: #c7c7c7;
  }
  .cnumber{
    width: 90px;
  }
  .ditem{
    padding: 5px;
    display: flex;
    justify-content: space-between;
  }
  .red {
    color: #ff0000;
  }
  .hand-btn {
    margin: 5px;
  }
  .gaoya{
    padding-left: 10px;
  }
  .search-inp{
    width: 130px;
  }
</style>
